package abacab.queue;

import abacab.actor.Actor;

/**
 * Represents a queue of actors. Implementations need to handle concurrent access.
 */
public abstract class ActorQueue {
	/**
	 * Indicates if the queue is empty.<br />
	 * For testing & debugging purpose => not necessarily quick.
	 * 
	 * @return true if the queue is empty
	 */
	public abstract boolean isEmpty();

	/**
	 * Get the number of queued items.<br />
	 * For testing & debugging purpose => not necessarily quick.
	 * 
	 * @return the number of queued items
	 */
	public abstract int size();

	/**
	 * Add an actor to the queue
	 * 
	 * @param actor
	 *          the actor
	 */
	public abstract <M> void offer(Actor<M> actor);

	/**
	 * Get the first suitable actor in the queue.<br />
	 * The implementation MUST return the first actor that succeeds in calling {@link Actor#isReadyForExecution()}. Other actors should be kept in the queue.
	 * 
	 * @return the first actor in the queue
	 */
	public abstract <M> Actor<M> poll();
}